package com.miplus.ccrm.core.service.strategy;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.miplus.ccrm.common.CmdResVo;
import com.miplus.ccrm.core.controller.vo.LabelResVo;
import com.miplus.ccrm.core.controller.vo.aicall.ObJobListReqVo;
import com.miplus.ccrm.core.controller.vo.aicall.ObJobListResVo;
import com.miplus.ccrm.core.controller.vo.strategy.CpListResVo;
import com.miplus.ccrm.core.pojo.CpCalllist;
import com.miplus.ccrm.core.pojo.ObJob;
import com.miplus.ccrm.core.mapper.ObJobMapper;
import com.miplus.ccrm.core.pojo.ObJobAgents;
import com.miplus.ccrm.core.pojo.ObJobStatus;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author wangzl
* @description 针对表【ob_job(AI外呼工作表)】的数据库操作Service实现
* @createDate 2025-02-08 01:15:51
*/
@Service
public class ObJobServiceImpl extends MPJBaseServiceImpl<ObJobMapper, ObJob>
    implements ObJobService{
    @Override
    public List<LabelResVo> selectAgentJobList(String agentId)
    {
        return selectJoinList(
                LabelResVo.class,
                new MPJLambdaWrapper<ObJob>()
                        .leftJoin(ObJobAgents.class, ObJobAgents::getJobid, ObJob::getJobid)
                        .leftJoin(CpCalllist.class,CpCalllist::getClid, ObJob::getJobid)
                        .leftJoin(ObJobStatus.class,ObJobStatus::getJobid, ObJob::getJobid)
                        .eq(ObJobAgents::getAgentid,agentId)
                        .eq(CpCalllist::getState,1)
                        .eq(ObJobStatus::getStatus,1)
                        .selectAs(ObJob::getJobid,LabelResVo::getValue)
                        .selectAs(CpCalllist::getName,LabelResVo::getLabel)

        );
    }
    @Override
    public CmdResVo updateJob(ObJob paras)
    {

        return null;
    }
    @Override
    public IPage<ObJobListResVo> getJobList(ObJobListReqVo paras)
    {
        return baseMapper.getJobList(new Page<>(paras.getPageNum(),paras.getPageSize()),paras.getChannel());
    }
}




